package com.noahsloan.groovy.util

import com.noahsloan.groovy.algorithms.GraphAlgorithms
import com.noahsloan.groovy.algorithms.GraphBuilderimport com.noahsloan.groovy.algorithms.Node
/**
 * @author noah
 *
 */
public class TestDelegateObject extends GroovyTestCase {
	
	def del
	
	void setUp() throws Exception{
		del = new DelegateObject(new MYObj())
	}

	void testProperty() {
		assertEquals( 123, del.baz )
		del.baz = 456
		assertEquals( 456, del.baz )
		assertEquals( null, del.mispilled )
		
		del = new DelegateObject(new Expando(foo:'bar'))
		assertEquals( 'bar', del.foo )		
	}
	
	void testRealMethod() {
		assertEquals( "1 2,3",del.foo(1,2,3) )
		del.foo = { a,b,c -> "abc" }
		assertEquals( "abc",del.foo(1,2,3) )
	}
	
	void testClosure() {
		assertEquals( "1,2 3",del.bar(1,2,3) )		
		del.bar = { a,b,c -> "abc" }
		assertEquals( "abc",del.bar(1,2,3) )
	}

	void testToString() {
		assertEquals("foobar",del.toString())
		del.toString = { "baz" }
		assertEquals("baz",del.toString())
	}
}
